Hi Guys, |
Re: How to count characters in a string?
You could do this by looping through the string and looking for the slashes, but if you are dealing with DOORS paths then the following might be more reliable/efficient:
string sPath = "/AMG/Red/Green/Blue/Black"
print(sPath "\n")
ModName_ m = module(sPath)
Folder f = getParentFolder(m)
while (!null f)
{
print(fullName(f) "\n")
f = getParentFolder(f)
}
|
Re: How to count characters in a string? Tony_Goodman - Fri Apr 17 05:38:18 EDT 2009
You could do this by looping through the string and looking for the slashes, but if you are dealing with DOORS paths then the following might be more reliable/efficient:
string sPath = "/AMG/Red/Green/Blue/Black"
print(sPath "\n")
ModName_ m = module(sPath)
Folder f = getParentFolder(m)
while (!null f)
{
print(fullName(f) "\n")
f = getParentFolder(f)
}
Regards, Manuel |
Re: How to count characters in a string? ManuelFelger - Fri Apr 17 05:55:46 EDT 2009
Of course it works ;-)
string sPath = "/AMG/Red/Green/Blue/Black"
print(sPath "\n")
int i = 0
for (i = length(sPath) - 1; i > 0; i--)
{
if (sPath[i] == '/')
{
print(sPath[0:i-1] "\n")
}
}
|